#ifndef _MSGBUS_IMSGBUS_H_
#define _MSGBUS_IMSGBUS_H_

#include <msgbus/imsg.h>
#include <msgbus/isession.h>

#define BROKER_ADDR_MAXLEN		250


#pragma pack (1)

typedef enum _eNODE_CLASS {
	NDC_NONE		= 0x00,
	NDC_BROKER		= 0x01,
	NDC_CONSUMER	= 0x02,
	NDC_PRODUCER	= 0x04,
	NDC_AGENT		= 0x08,
	NDC_REQ			= 0x10,
	NDC_REP			= 0x20
}NODE_CLASS;

#define	IS_BROKER(CLASS)	((NODE_CLASS)(CLASS) == NDC_BROKER)
#define IS_PRODUCER(CLASS)	((NODE_CLASS)(CLASS) == NDC_PRODUCER)
#define IS_CONSUMER(CLASS)	((NODE_CLASS)(CLASS) == NDC_CONSUMER)
#define IS_AGENT(CLASS)		((NODE_CLASS)(CLASS) == NDC_AGENT)
#define IS_REQ(CLASS)		((NODE_CLASS)(CLASS) == NDC_REQ)
#define IS_REP(CLASS)		((NODE_CLASS)(CLASS) == NDC_REP)

#pragma pack ()

interface IBroker : public IBase
{
	std_method(Listen)(LPCSTR addr, int len, int maxconn) PURE;
	std_method(Dispatch)(unsigned int sec) PURE;
	std_method(Close)() PURE;
	std_method(IsListen)() PURE;
};

// {A1DA4FBA-D0DB-434D-ABC5-ACF313391D4D}
_DEFINE_IID(IID_IBroker,
	0xa1da4fba, 0xd0db, 0x434d, 0xab, 0xc5, 0xac, 0xf3, 0x13, 0x39, 0x1d, 0x4d);




interface IProducer : public IBase
{
	std_method(SetId)(unsigned int id) PURE;
	std_method(Bind)(LPCSTR addr, int len) PURE;
	std_method(Close)() PURE;
	std_method(Send)(IBase* pBase) PURE;
};

// {8FF17375-E568-4F48-95CC-5E26DC896C53}
_DEFINE_IID(IID_IProducer,
	0x8ff17375, 0xe568, 0x4f48, 0x95, 0xcc, 0x5e, 0x26, 0xdc, 0x89, 0x6c, 0x53);

interface IConsumer : public IBase
{
	std_method(SetId)(unsigned int id) PURE;
	std_method(Bind)(LPCSTR addr, int len) PURE;
	std_method(Close)() PURE;
	std_method(Recv)(IBase* pBase) PURE;
};

// {8FF17375-E568-4F48-95CC-5E26DC896C53}
_DEFINE_IID(IID_IConsumer,
	0x8ff17375, 0xe568, 0x4f48, 0x95, 0xcc, 0x5e, 0x26, 0xdc, 0x89, 0x6c, 0x53);

interface IAgent : public IBase
{
	std_method(SetId)(unsigned int id) PURE;
	std_method(Bind)(LPCSTR addr, int len) PURE;
	std_method(Close)() PURE;
	std_method(Recv)(IBase* pBase) PURE;
	std_method(Send)(IBase* pBase) PURE;
};

// {F2559910-4D1A-477B-A42B-73A695BF32DC}
_DEFINE_IID(IID_IAgent,
	0xf2559910, 0x4d1a, 0x477b, 0xa4, 0x2b, 0x73, 0xa6, 0x95, 0xbf, 0x32, 0xdc);



// {13999C4F-52E7-4E5B-98A4-118D0D61A092}
_DEFINE_IID(IID_IReq,
	0x13999c4f, 0x52e7, 0x4e5b, 0x98, 0xa4, 0x11, 0x8d, 0xd, 0x61, 0xa0, 0x92);

// {C6A35621-A012-4C75-991E-D5625F5E3981}
_DEFINE_IID(IID_IRep,
	0xc6a35621, 0xa012, 0x4c75, 0x99, 0x1e, 0xd5, 0x62, 0x5f, 0x5e, 0x39, 0x81);

interface IMsgBus : public IBase
{
	std_method(CreateNode)(NODE_CLASS cls, IBase** pBase) PURE;
};

// {457CFBD8-5547-471F-B027-DDFF47A9238A}
_DEFINE_IID(IID_IMsgBus,
	0x457cfbd8, 0x5547, 0x471f, 0xb0, 0x27, 0xdd, 0xff, 0x47, 0xa9, 0x23, 0x8a);

// {201409F6-22F8-48d3-A69F-7935BDDE6BFF}
_DEFINE_GUID(CLSID_IMsgBus,
			0x201409f6, 0x22f8, 0x48d3, 0xa6, 0x9f, 0x79, 0x35, 0xbd, 0xde, 0x6b, 0xff);

#endif 
